package org.fordprefect.struts2jscalendarplugin.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.TextFieldTag;
import org.fordprefect.struts2jscalendarplugin.components.JSCalendar;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * @see org.fordprefect.struts2jscalendarplugin.components.JSCalendar
 */
@SuppressWarnings("serial")
public class JSCalendarTag extends TextFieldTag {

	protected String format;
	protected String showstime;
	protected String singleclick;
	protected String flat;
	protected String flatCallback;

	@Override
	public Component getBean(ValueStack stack, HttpServletRequest req,
			HttpServletResponse res) {
		return new JSCalendar(stack, req, res);
	}

	@Override
	protected void populateParams() {
		super.populateParams();
		final JSCalendar jsCalendar = (JSCalendar) component;
		jsCalendar.setFormat(format);
		jsCalendar.setShowstime(showstime);
		jsCalendar.setSingleclick(singleclick);
		jsCalendar.setFlat(flat);
		jsCalendar.setFlatCallback(flatCallback);
		jsCalendar.setReadonly(readonly);
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public void setShowstime(String showstime) {
		this.showstime = showstime;
	}

	public void setSingleclick(String singleclick) {
		this.singleclick = singleclick;
	}

	public void setFlat(String flat) {
		this.flat = flat;
	}

	public void setFlatCallback(String flatCallback) {
		this.flatCallback = flatCallback;
	}

}
